home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / mus / play / oplay1231.lha / src / oplay.c < prev    next >
C/C++ Source or Header  |  1993-01-31  |  16KB  |  618 lines

  1. /*
  2.  * OmniPlay, v1.23
  3.  * by David Champion
  4.  *
  5.  * command parser & playroutine
  6.  * 19 Nov 92
  7.  */
  8.  
  9.  
  10. #include <exec/types.h>
  11. #include <exec/exec.h>
  12.  
  13. #include <graphics/gfxbase.h>
  14. #include <dos/dos.h>
  15. #include <devices/audio.h>
  16.  
  17. #include <stdlib.h>
  18. #include <string.h>
  19. #include <stdio.h>
  20.  
  21. #include "oplay.h"
  22. #include "forms.h"
  23.  
  24. extern struct library *DOSBase;
  25.  
  26. /*
  27.  * libraries/mathffp.h from clib/alib_protos.h prototypes abs(),
  28.  * which conflicts with stdlib.h
  29.  */
  30. #ifndef    LIBRARIES_MATHFFP_H
  31. #define    LIBRARIES_MATHFFP_H 1
  32. #endif    /* LIBRARIES_MATHFFP_H */
  33. #include <clib/alib_protos.h>
  34. #include <clib/exec_protos.h>
  35. #include <pragmas/exec_lib.h>
  36. #include <clib/dos_protos.h>
  37. #include <pragmas/dos_lib.h>
  38. #include <pragmas/powerpacker.h>
  39.  
  40. /* prototypes */
  41. //void    main(int, char **);
  42. void    parsecli(int, char **);
  43. void    play(char *);
  44. void    info(char *, char *);
  45. UWORD    toperiod(const UWORD);
  46. struct IOAudio    *GetIOB(ULONG);
  47. struct IOAudio    *CopyIOB(struct IOAudio *);
  48. void    FreeIOB(struct IOAudio *);
  49. void    FreeCopy(struct IOAudio *);
  50. ULONG    LoadIOB(BPTR, struct IOAudio *, ULONG, char *);
  51. void    clean(int);
  52. void    Usage(int);
  53. int    TokenizeString(char *, char **);
  54. extern    ULONG    readfile(char *);
  55. extern    void    propinfo(char *, char *, ULONG);
  56. extern    char    *tmpnam(char *);
  57.  
  58. /* constants */
  59. UBYTE    ch_l[4]    = {1, 8, 1, 8};
  60. UBYTE    ch_r[4]    = {2, 4, 2, 4};
  61. UBYTE    ch_e[4]    = {1, 4, 2, 8};
  62. UBYTE    ch_s[4]    = {3, 5, 10, 12};
  63.  
  64. /* globals */
  65. char version[] = "$VER: OmniPlay 1.231 (31.1.93)";
  66. BPTR    fp;
  67. BPTR    writefp;
  68. UBYTE    *chan        = ch_e;
  69. ULONG    len;
  70. char    utype        = AUTO;
  71. UWORD    uvol        = 0;
  72. UWORD    urate        = 0;
  73. UWORD    vol        = 0;
  74. UWORD    rate        = 0;
  75. ULONG    ubufsiz        = 4000;
  76. ULONG    bufsiz;
  77. BOOL    oneshot        = 0;
  78. char    *myname;
  79. char    cvmode        = CV_NONE;
  80. BOOL    showprops    = 1;
  81. UWORD    displaymode    = NTSC;
  82. LONG    oldpri;
  83. BOOL    genulawtab    = 0;
  84. BOOL    showmax        = 0;
  85. int    max;
  86. int    amplify        = 1;
  87. //int    Amplify        = 1;
  88. BOOL    fileinfo    = 0;
  89. char    *writefn;
  90. int    totallen;
  91. FILE    *mystdout;
  92. int    RptCycles    = 1;
  93. signed char        logs[256];
  94. struct Library        *PPBase;
  95.  
  96. extern    char    pptmp[];
  97. extern    BOOL    ppuse;
  98.  
  99.  
  100. void main(int ac, char **av)
  101. {
  102. struct GfxBase    *GfxBase;
  103. char    env[CMDMAXLEN+1];
  104. int    envc;
  105. char    *envv[CMDMAXLEN+1];
  106. char    *envl;
  107.  
  108.     oldpri = SetTaskPri((struct Task *)FindTask(NULL), -1);
  109.  
  110.     if ( !ac ) exit(0);        /* No WB usage */
  111.  
  112.     myname=av[0];
  113.  
  114.     mystdout = stdout;
  115.  
  116.     if ( GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0L) ) {
  117.         displaymode = GfxBase->DisplayFlags;    /* PAL or NTSC? */
  118.         CloseLibrary((struct Library *)GfxBase);
  119.     }
  120.     else info("Can't get display mode; assuming NTSC", myname);
  121.  
  122.         /* get pplib */
  123.     PPBase = (struct Library *)OpenLibrary("powerpacker.library", 33L);
  124.  
  125.      if ( ac == 1 ) {
  126.         Usage(0);
  127.         clean(0);
  128.     }
  129.     shift;
  130.  
  131.     if ( envl=getenv("OMNIPLAY") ) {
  132.         strncpy(env, envl, CMDMAXLEN);
  133.         if ( (envc=TokenizeString(env, envv)) != 0 ) parsecli(envc, envv);
  134.     }
  135.     parsecli(ac, av);
  136.  
  137.     clean(0);
  138. }
  139.  
  140. void parsecli(int ac, char **av)
  141. {
  142. char    option;
  143. char    *optarg;
  144. LONG    pri;
  145.  
  146.     while ( ac > 0 ) {
  147.         if ( USERBREAK ) {
  148.             info("User break", myname);
  149.             break;
  150.         }
  151.         if ( av[0][0] ==  '-' ) {
  152.             option    = av[0][1];
  153.             if ( strlen(av[0]) == 2 ) {
  154.                 shift;
  155.                 optarg=av[0];
  156.             }
  157.             else optarg=&av[0][2];
  158.             switch ( option ) {
  159.             case    'h':
  160.                 Usage(1);
  161.                 break;
  162.             case    'v':
  163.                 uvol = atoi(optarg);
  164.                 break;
  165.             case    'r':
  166.                 urate = atoi(optarg);
  167.                 break;
  168.             case    'c':
  169.                 if ( optarg[0] == 'l' ) chan = ch_l;
  170.                 else if ( optarg[0] == 'r' ) chan = ch_r;
  171.                 else if ( optarg[0] == 'e' ) chan = ch_e;
  172.                 else if ( optarg[0] == 's' ) chan = ch_e;
  173.                 else {
  174.                     info("Unknown channel", optarg);
  175.                     clean(10);
  176.                 }
  177.                 break;
  178.             case    'o':
  179.                 if ( (strcmp(optarg, "0")) && (strcmp(optarg, "1")) ) info("Bad usage of -o option", av[0]);
  180.                 else oneshot = (BOOL)atoi(optarg);
  181.                 break;
  182.             case    'b':
  183.                 ubufsiz = atoi(optarg);
  184.                 break;
  185.             case    'p':
  186.                 pri = atoi(optarg);
  187.                 if ( ( pri < -10 ) || (pri > 10) ) {
  188.                     info("Can't change priority out of {-10, 10}", av[0]);
  189.                     break;
  190.                 }
  191.                 SetTaskPri((struct Task *)FindTask(NULL), pri);
  192.                 break;
  193.             case    'w':
  194.                 Delay(atoi(optarg));
  195.                 break;
  196.             case    's':
  197.                 if ( (strcmp(optarg, "0")) && (strcmp(optarg, "1")) ) info("Bad usage of -s option", av[0]);
  198.                 else showprops = (BOOL)atoi(optarg);
  199.                 break;
  200.             case    'd':
  201.                 if ( !strcmp(optarg, "PAL") ) displaymode = PAL;
  202.                 else if ( !strcmp(optarg, "NTSC") ) displaymode = NTSC;
  203.                 else info("Bad usage of -d option", av[0]);
  204.                 break;
  205.             case    'f':
  206.                 if ( strlen(optarg) != 1 ) {
  207.                     info("Bad usage of -f option", av[0]);
  208.                     break;
  209.                 }
  210.                 switch( optarg[0] ) {
  211.                 case    'u':
  212.                     utype = RAWU;
  213.                     break;
  214.                 case    's':
  215.                     utype = RAWS;
  216.                     break;
  217.                 case    'l':
  218.                     utype = RAWL;
  219.                     break;
  220.                 case    'a':
  221.                     utype = AUTO;
  222.                     break;
  223.                 default:
  224.                     info("Bad usage of -f option", av[0]);
  225.                     break;
  226.                 }
  227.                 break;
  228.             case    'g':
  229.                 if ( (strcmp(optarg, "0")) && (strcmp(optarg, "1")) ) info("Bad usage of -g option", av[0]);
  230.                 else genulawtab = (BOOL)atoi(optarg);
  231.                 break;
  232.             case    'm':
  233.                 if ( (strcmp(optarg, "0")) && (strcmp(optarg, "1")) ) info("Bad usage of -m option", av[0]);
  234.                 else showmax = (BOOL)atoi(optarg);
  235.                 break;
  236.             case    'a':
  237.                 amplify = atoi(optarg);
  238.                 break;
  239. //            case    'A':
  240. //                Amplify = atoi(optarg);
  241. //                break;
  242.             case    'i':
  243.                 if ( (strcmp(optarg, "0")) && (strcmp(optarg, "1")) ) info("Bad usage of -i option", av[0]);
  244.                 else fileinfo = atoi(optarg);
  245.                 break;
  246.             case    'W':
  247.                 writefn = optarg;
  248.                 break;
  249.             case    'O':
  250.                 if ( mystdout != stdout ) {
  251.                     info("Output can be changed only once", av[0]);
  252.                     break;
  253.                 }
  254.                 mystdout = fopen(optarg, "w");
  255.                 break;
  256.             case    'R':
  257.                 RptCycles = atoi(optarg);
  258.                 break;
  259.             case    '-':
  260.                 {
  261.                     char tmp[CMDMAXLEN+1];
  262.                     tmp[0] = '-';
  263.                     strncpy(&tmp[1], optarg, CMDMAXLEN-1);
  264.                     play( tmp );
  265.                     if ( writefn ) writefn = NULL;
  266.                     if ( ppuse ) {
  267.                         DeleteFile(pptmp);
  268.                         ppuse=0;
  269.                     }
  270.                 }
  271.                 break;
  272.             default:
  273.                 info("Unknown option", av[0]);
  274.                 break;
  275.             }
  276.         }
  277.         else {
  278.             play( av[0] );
  279.             if ( writefn ) writefn = NULL;
  280.             if ( ppuse ) {
  281.                 DeleteFile(pptmp);
  282.                 ppuse=0;
  283.             }
  284.         }
  285.         shift;
  286.     }
  287.     return;
  288. }
  289.  
  290. void play(char *fn)
  291. {
  292. struct IOAudio    *buf1, *buf2;
  293. register ULONG    size;
  294. register int    b2used=0;
  295. int rptcycles    = RptCycles;
  296. ULONG datastart;
  297. int origlen;
  298.  
  299.     if ( showprops ) fprintf(mystdout, "\n"COL3"File      : %s"COL1"\n", fn);
  300.  
  301.     if ( writefn ) {
  302.         totallen = 40;
  303.         if ( !(writefp = (BPTR) Open(writefn, MODE_NEWFILE)) ) {
  304.             info("Can't open IFF output", "-W");
  305.             writefn = NULL;
  306.         }
  307.     else Write((BPTR)writefp, "FORM----8SVXVHDR\000\000\000\024++++----++++----++++", 40);
  308.     }
  309.  
  310.     if ( (len = readfile(fn)) == 0L ) return;
  311.     origlen = len;
  312.     datastart = Seek(fp, 0, OFFSET_CURRENT);
  313.  
  314. //    bufsiz = oneshot ? (len/2)+1 : ubufsiz;
  315.     bufsiz = oneshot ? len : ubufsiz;
  316.  
  317.     if ( fileinfo ) {
  318.         char    *style_str[] = {
  319.             "8-bit",
  320.             "16-bit",
  321.             "signed",
  322.             "unsigned",
  323.             "u-law"
  324.         };
  325.  
  326.         fprintf(mystdout, "Rate\t= %d\n", rate);
  327.         fprintf(mystdout, "Volume\t= %d\n", vol);
  328.         fprintf(mystdout, "Length\t= %d\n", len);
  329.         fprintf(mystdout, "Buffers\t= %d\n", bufsiz);
  330.         fprintf(mystdout, "Style\t= %s %s\n", style_str[(cvmode&4)>>2], style_str[(cvmode&3)+2]);
  331.     }
  332.     if ( showmax && (cvmode & CV_ULAW) ) fprintf(mystdout, "Ulaw max= %d.\n", max);
  333.  
  334.     if ( writefn ) {
  335.     struct Voice8Header    vhdr = {0, 0, 0, 10000, 1, 0, 64<<10};
  336.         vhdr.oneShotHiSamples = len;
  337.         vhdr.samplesPerSec = rate;
  338.         vhdr.volume = vol;
  339.  
  340.         totallen += len;
  341.         Seek((BPTR)writefp, 4, OFFSET_BEGINNING);
  342.         Write((BPTR)writefp, &totallen, 4);
  343.         Seek((BPTR)writefp, 20, OFFSET_BEGINNING);
  344.         Write((BPTR)writefp, &vhdr, sizeof(struct  Voice8Header));
  345.         Seek((BPTR)writefp, 0, OFFSET_END);
  346.         Write((BPTR)writefp, "BODY", 4);
  347.         Write((BPTR)writefp, &len, 4);
  348.     }
  349.  
  350.     fflush(mystdout);
  351.  
  352.     rate = toperiod(rate);
  353.  
  354.     if ( !(buf1 = (struct IOAudio *)GetIOB(bufsiz)) ) {
  355.         info("Can't allocate buffer one", fn);
  356.         Close((BPTR)fp);
  357.         return;
  358.     }
  359.     buf1->ioa_Period = rate;
  360.     buf1->ioa_Volume = vol;
  361.     buf1->ioa_Cycles = 1;
  362.     if ( len > bufsiz ) {
  363.         if ( !(buf2 = (struct IOAudio *)CopyIOB(buf1)) ) {
  364.             info("Can't allocate buffer two", fn);
  365.             FreeIOB(buf1);
  366.             Close((BPTR)fp);
  367.             return;
  368.         }
  369.     }
  370.     else buf2 = NULL;
  371.  
  372.     while ( rptcycles-- ) {
  373.         do {
  374.             if ( USERBREAK ) {
  375.                 info("User break", fn);
  376.                 len = 0;
  377.             }
  378.             if ( len <= 0 ) {
  379.                 if ( b2used ) WaitIO((struct IORequest *)buf2);
  380.                 break;
  381.             }
  382.             size = MIN(len, bufsiz);
  383.             if ( !LoadIOB(fp, buf1, size, fn) ) {
  384.                 if ( b2used ) WaitIO((struct IORequest *)buf2);
  385.                 break;
  386.             }
  387.             len -= size;
  388.             buf1->ioa_Length = size;
  389.             BeginIO((struct IORequest *)buf1);
  390.  
  391.             if ( b2used ) WaitIO((struct IORequest *)buf2);
  392.             if ( USERBREAK ) {
  393.                 info("User break", fn);
  394.                 len = 0;
  395.             }
  396.             if ( len <= 0 ) {
  397.                 WaitIO((struct IORequest *)buf1);
  398.                 break;
  399.             }
  400.             size = MIN(len, bufsiz);
  401.             if ( !LoadIOB(fp, buf2, size, fn) ) {
  402.                 WaitIO((struct IORequest *)buf1);
  403.                 break;
  404.             }
  405.             b2used++;
  406.             len -= size;
  407.             buf2->ioa_Length = size;
  408.             BeginIO((struct IORequest *)buf2);
  409.  
  410.             WaitIO((struct IORequest *)buf1);
  411.         } while ( TRUE );
  412.     Seek(fp, datastart, OFFSET_BEGINNING);
  413.     len = origlen;
  414.     }
  415.  
  416.     FreeIOB(buf1);
  417.     if ( buf2 ) FreeCopy(buf2);
  418.  
  419.     Close((BPTR)fp);
  420.     if ( writefn ) Close((BPTR)writefp);
  421.  
  422.     return;
  423. }
  424.  
  425. void info(char *msg, char *offender)
  426. {
  427.     fprintf(mystdout, "%s: %s: %s\n", myname, offender, msg);
  428.     return;
  429. }
  430.  
  431. UWORD toperiod(const UWORD sps)
  432. {
  433.     if ( displaymode == PAL  )    return( (UWORD)((1000000000 / 281)/sps) );
  434.         /* not PAL, assume NTSC (GENLOC not an option here... */
  435.     else                return( (UWORD)((1000000000 / 279)/sps) );
  436. }
  437.  
  438. struct IOAudio *GetIOB(ULONG size)
  439. {
  440. struct IOAudio    *IOB;
  441. void    *buf;
  442. struct MsgPort    *port;
  443.  
  444.     if ( !(port = (struct MsgPort *)CreatePort("omniplay", 0)) ) return(NULL);
  445.     if ( !(buf  = (void *)AllocMem(size, MEMF_CHIP)) ) {
  446.         DeletePort(port);
  447.         return(NULL);
  448.     }
  449.     if ( !(IOB = (struct IOAudio *)AllocMem(sizeof(struct IOAudio), MEMF_PUBLIC|MEMF_CLEAR)) ) {
  450.         DeletePort(port);
  451.         FreeMem(buf, size);
  452.         return(NULL);
  453.     }
  454.     IOB->ioa_Request.io_Message.mn_Node.ln_Pri = 0;
  455.     IOB->ioa_Request.io_Message.mn_ReplyPort = port;
  456.     IOB->ioa_Data = chan;
  457.     IOB->ioa_Length = 4;
  458.     IOB->ioa_Request.io_Command = ADCMD_ALLOCATE;
  459.     OpenDevice("audio.device", 0, (struct IORequest *)IOB, 0);
  460.     if ( !IOB->ioa_AllocKey ) {
  461.         DeletePort(port);
  462.         FreeMem(buf, size);
  463.         FreeMem(IOB, sizeof(struct IOAudio));
  464.         return(NULL);
  465.     }
  466.     IOB->ioa_Request.io_Command = CMD_WRITE;
  467.     IOB->ioa_Request.io_Flags = ADIOF_PERVOL;
  468.     IOB->ioa_Data = buf;
  469.     IOB->ioa_Length = size;
  470.  
  471.     return((struct IOAudio *)IOB);
  472. }
  473.  
  474. struct IOAudio *CopyIOB(struct IOAudio *oldIOB)
  475. {
  476. struct IOAudio *IOB;
  477. void     *buf;
  478.  
  479.     if ( !oldIOB ) return(NULL);
  480.     if ( !(buf = (void *)AllocMem(oldIOB->ioa_Length, MEMF_CHIP)) ) return(NULL);
  481.     if ( !(IOB = (struct IOAudio *)AllocMem(sizeof(struct IOAudio), MEMF_PUBLIC|MEMF_CLEAR)) ) {
  482.         FreeMem(buf, oldIOB->ioa_Length);
  483.         return(NULL);
  484.     }
  485.     CopyMem(oldIOB, IOB, sizeof(struct IOAudio));
  486.     IOB->ioa_Data = buf;
  487.     return((struct IOAudio *)IOB);
  488. }
  489.  
  490. void FreeIOB(struct IOAudio *IOB)
  491. {
  492.     if ( !IOB ) return;
  493.     if ( IOB->ioa_Data ) FreeMem((UBYTE *)IOB->ioa_Data, bufsiz);
  494.     IOB->ioa_Request.io_Command = ADCMD_FREE;
  495.     BeginIO((struct IORequest *)IOB);
  496.     WaitIO((struct IORequest *)IOB);
  497.     DeletePort(IOB->ioa_Request.io_Message.mn_ReplyPort);
  498.     CloseDevice((struct IORequest *)IOB);
  499.     FreeMem(IOB, sizeof(struct IOAudio));
  500.     return;
  501. }
  502.  
  503. void FreeCopy(struct IOAudio *IOB)
  504. {
  505.     if ( !IOB ) return;
  506.     if ( IOB->ioa_Data ) FreeMem((UBYTE *)IOB->ioa_Data, bufsiz);
  507.     FreeMem(IOB, sizeof(struct IOAudio));
  508.     return;
  509. }
  510.  
  511. ULONG LoadIOB(BPTR lfp, struct IOAudio *IOB, ULONG size, char *fn)
  512. {
  513. register int    i;
  514. register UBYTE    *iodata;
  515. //LONG    j;
  516.  
  517.     if ( !size ) return(0L);
  518.  
  519.     iodata = IOB->ioa_Data;
  520.  
  521.     if ( cvmode & CV_DOWN ) {
  522.         UWORD    tmp;
  523.         if ( cvmode & CV_BEND ) {
  524.             for(i=0; i<size; i++) {
  525.                 Read((BPTR)lfp, &tmp, 2);
  526.                 iodata[i] = (UBYTE)(tmp >> 8);
  527.             }
  528. //            IOB->ioa_Length = size;
  529.         }
  530.         else if ( cvmode & CV_LEND ) {
  531.             for(i=0; i<size; i++) {
  532.                 Read((BPTR)lfp, &tmp, 2);
  533.                 iodata[i] = (UBYTE)(tmp & 0xff);
  534.             }
  535. //            IOB->ioa_Length = size;
  536.         }
  537.     }
  538. //    else IOB->ioa_Length = Read((BPTR)lfp, iodata, size);
  539.     else Read((BPTR)lfp, iodata, size);
  540.  
  541.     if ( cvmode & CV_ULAW ) {
  542.         for(i=0; i<size; i++) iodata[i] = logs[iodata[i]];
  543.     }
  544.     if ( cvmode & CV_FLIP ) {
  545.         for(i=0; i<size; i++) iodata[i] ^= 0x80;
  546.     }
  547.  
  548.     if ( amplify != 1 ) for(i=0; i<size; i++) iodata[i] = (signed char)(iodata[i] * amplify);
  549. //    if ( Amplify != 1 ) for(i=0; i<size; i++) {
  550. //        j = (LONG)(iodata[i] * Amplify / 100);
  551. //        iodata[i] = (signed char)(j<0 ? MIN(j, -128) : MAX(j, 127));
  552. //    }
  553.  
  554.     if ( writefn ) Write((BPTR)writefp, iodata, size);
  555.  
  556.     return(IOB->ioa_Length);
  557. }
  558.  
  559. void clean(int code)
  560. {
  561.     if ( mystdout != stdout ) {
  562.         fclose(mystdout);
  563.     }
  564.     SetTaskPri((struct Task *)FindTask(NULL), oldpri);
  565.     if ( PPBase ) CloseLibrary((struct Library *)PPBase);
  566.     exit(code);
  567. }
  568.  
  569. void Usage(int degree)
  570. {
  571.     fprintf(mystdout, "%s: Usage:\n", &version[6]);
  572.     fprintf(mystdout, "%s\t[-h] [-b"COL3"bufsize"COL1"] [-c"COL3"l|r|e"
  573.         COL1"] [-r"COL3"rate"COL1"] [-v"COL3"volume"COL1"] [-f"
  574.         COL3"a|l|s|u"COL1"]\n", myname);
  575.     fprintf(mystdout, "\t[-w"COL3"ticks"COL1"] [-s"COL3"0|1"COL1"] [-p"
  576.         COL3"pri"COL1"] [-d"COL3"PAL|NTSC"COL1"] [-g"COL3"0|1"COL1
  577.         "] [-m"COL3"0|1"COL1"] [-o"COL3"0|1"COL1"]\n");
  578.     fprintf(mystdout, "\t[-O"COL3"filespec"COL1"] [-a"COL3"factor"COL1/*"] [-A"COL3
  579.         "factor"COL1*/"] [-W"COL3"filename"COL1"] [--"COL3"file"COL1
  580.         "] "COL3"file [...]"COL1"\n\n");
  581.     if ( !degree ) fprintf(mystdout, "Use "COL3"oplay -h"COL1" for extended usage information.\n");
  582.     if ( degree ) {
  583.         fprintf(mystdout, "\t-h:\thelp.  This stuff here.\n");
  584.         fprintf(mystdout, "\t-b:\tsize of one audio buffer (there are two).\n");
  585.         fprintf(mystdout, "\t-c:\tchannel: left, right, or either.\n");
  586.         fprintf(mystdout, "\t-r:\toverride sound file's playback rate, in samples per second.\n");
  587.         fprintf(mystdout, "\t-v:\toverride sound file's volume.  0 <= volume <= 64.\n");
  588.         fprintf(mystdout, "\t-f:\tforce playback as Auto, u-Law, Signed raw, or Unsigned raw.\n");
  589.         fprintf(mystdout, "\t-w:\tpause between sounds.  One tick is 1/50 second.\n");
  590.         fprintf(mystdout, "\t-p:\tset %s's task priority.\n", myname);
  591.         fprintf(mystdout, "\t-s:\tshow (1) or don't show (0) optional properties.\n");
  592.         fprintf(mystdout, "\t-d:\toverride default electrical standard.\n");
  593.         fprintf(mystdout, "\t-g:\tgenerate log tables for ulaw files.\n");
  594.         fprintf(mystdout, "\t-m:\tshow maximum encoded value for ulaw files.\n");
  595.         fprintf(mystdout, "\t-o:\toneshot; override buffersize, loading whole file at once.\n");
  596.         fprintf(mystdout, "\t-O:\tspecify output file or window.\n");
  597.         fprintf(mystdout, "\t-a:\tamplify; multiplies loudness by the given integer.\n");
  598. //        fprintf(mystdout, "\t-A:\tamplify; multiplies loudness by the given integer (cropped).\n");
  599.         fprintf(mystdout, "\t-i:\tdisplay arcane sound information\n");
  600.         fprintf(mystdout, "\t-W:\twrite the file as IFF.\n");
  601.         fprintf(mystdout, "\t--:\tplay a file whose name begins with '-'.\n\n");
  602.         fprintf(mystdout, "Any argument can appear anywhere.  Options take effect as processed, after\n");
  603.         fprintf(mystdout, "any preceding files have been played.  You can use this to readjust OmniPlay's\n");
  604.         fprintf(mystdout, "settings on a per-sound basis.  To remove rate or volume override, use\n");
  605.         fprintf(mystdout, "-r0 or -v0.  To remove amplification, use -a1.\n");
  606.     }
  607.     return;
  608. }
  609.  
  610. int TokenizeString(char *line, char **av)
  611. {
  612. int    ac    = 0;
  613.  
  614.     av[ac++] = (char *)strtok(line, " ");
  615.     while ( av[ac++] = (char *)strtok(NULL, " ") );
  616.     return(--ac);
  617. }
  618.